
*	************************************************************************
* 	File-Name: 	appendix.do
*	Log-file:	n/a
*	Date:  		1 August 2017
*	Author: 	Michael Aklin, Patrick Bayer, S.P. Harish, and Johannes Urpelainen
*	Data Used:  adoption_data.dta (through prep.do)
*	Output		n/a
*	Purpose:   	replication file for robustness checks in appendix
*	************************************************************************

capture log close
clear all
set more off

*	************************************************************************
*	Load data
*	************************************************************************

* Run prep.do to set data up for analysis, create variables and correct labels
do "./prep.do"


*	************************************************************************
*	Appendix A3: Summary statistics and data description
*	************************************************************************

* Table A1: Summary statistics (full sample)
eststo clear
eststo: estpost sum logexpenses logsavings debt risk business riskaverse trust_people_index trust_firms_index logpublic logprivate elec size age educ scheduled backward satisfaction expend if survey==1

* Table A2: Summary statistics (adopting HHs in MGP habitation)
eststo clear
eststo: estpost sum logexpenses logsavings debt risk business riskaverse trust_people_index trust_firms_index logpublic logprivate elec size age educ scheduled backward satisfaction expend if survey==1 & adopted==1 & installed==1

* Table A3: Summary statistics (non-adopting HHs in MGP habitation)
eststo clear
eststo: estpost sum logexpenses logsavings debt risk business riskaverse trust_people_index trust_firms_index logpublic logprivate elec size age educ scheduled backward satisfaction expend if survey==1 & adopted==0 & installed==1

* Table A4: Summary statistics (Habitations w/o MGP service)
eststo clear
eststo: estpost sum logexpenses logsavings debt risk business riskaverse trust_people_index trust_firms_index logpublic logprivate elec size age educ scheduled backward satisfaction expend if survey==1 & installed==0

* Table A5: Means by adoption status (HH and habitation level)
* NB: Requires 'orth_out.pkg'

* Create two additional variables for comparison
gen Hindu = 0
replace Hindu = 1 if Q37_religion==1
gen Muslim = 0
replace Muslim = 1 if Q37_religion==2

* Household level information in Table A5
orth_out logexpenses logsavings debt risk business riskaverse trust_people_index ///
trust_firms_index logpublic logprivate elec size age educ scheduled backward satisfaction expend Hindu Muslim ///
if survey==1 using "household_means.tex", by(adopted) bdec(2) armlabel("Adopting HHs" "Non-adopting HHs") full count latex replace


* Write local macro for variable names
foreach v of var * {
	local l`v' : variable label `v'
        if `"`l`v''"' == "" {
 		local l`v' "`v'"
  	}
}

* Collapse data
collapse (first) installed (mean) logexpenses logsavings debt risk business riskaverse trust_people_index ///
trust_firms_index logpublic logprivate elec size age educ scheduled backward satisfaction expend Hindu Muslim if survey==1, by(unique_id)

* Assign variable names
foreach v of var * {
 	label var `v' "`l`v''"
 }


* Habitation level information in Table A5
orth_out logexpenses logsavings debt risk business riskaverse trust_people_index ///
trust_firms_index logpublic logprivate elec size age educ satisfaction expend Hindu Muslim ///
using "habitation_means.tex", by(installed) bdec(2) armlabel("w/o MGP service" "with MGP service") full count latex replace

* Table A6: Adoption by habitation and survey wave
* Make sure to load data
clear all
do "./prep.do"

collapse (first) Q24_village Q25_hamlet installed (count) Q11_hhid (sum) scheduled backward other tvadopted if survey!=1, by(unique_id survey)
gen share = tvadopted/ Q11_hhid
sort Q24_village Q25_hamlet survey
list

*	************************************************************************
*	Appendix A4: Regression results (OLS, panel)
*	************************************************************************

* Make sure to load data
clear all
do "./prep.do"

* Make sure that covariates are pre-treatment
tsset Q11_hhid survey
by Q11_hhid: replace L1logexpenses = L1logexpenses[2] if survey==3
by Q11_hhid: replace L1logsavings = L1logsavings[2] if survey==3 
by Q11_hhid: replace L1debt = L1debt[2] if survey==3
by Q11_hhid: replace L1risk = L1risk[2] if survey==3
by Q11_hhid: replace L1business = L1business[2] if survey==3
by Q11_hhid: replace L1riskaverse = L1riskaverse[2] if survey==3
by Q11_hhid: replace L1trust_people_index = L1trust_people_index[2] if survey==3
by Q11_hhid: replace L1trust_firms_index = L1trust_firms_index[2] if survey==3
by Q11_hhid: replace L1logpublic = L1logpublic[2] if survey==3
by Q11_hhid: replace L1logprivate = L1logprivate[2] if survey==3
by Q11_hhid: replace L1elec = L1elec[2] if survey==3
by Q11_hhid: replace L1size = L1size[2] if survey==3
by Q11_hhid: replace L1age = L1age[2] if survey==3
by Q11_hhid: replace L1educ = L1educ[2] if survey==3
by Q11_hhid: replace L1scheduled = L1scheduled[2] if survey==3
by Q11_hhid: replace L1backward = L1backward[2] if survey==3
by Q11_hhid: replace L1satisfaction = L1satisfaction[2] if survey==3
by Q11_hhid: replace L1expend = L1expend[2] if survey==3

* Replication of main model results with OLS

eststo clear

* Full sample models
eststo: xtreg tvadopted L1logexpenses L1logsavings L1debt, vce(cluster unique_id)
eststo: xtreg tvadopted L1logexpenses L1logsavings L1debt L1risk L1business L1riskaverse, vce(cluster unique_id)
eststo: xtreg tvadopted L1logexpenses L1logsavings L1debt L1risk L1business L1riskaverse L1trust_people_index L1trust_firms_index, vce(cluster unique_id)
eststo: xtreg tvadopted L1logexpenses L1logsavings L1debt L1risk L1business L1riskaverse L1trust_people_index L1trust_firms_index L1logpublic L1logprivate L1elec L1size L1age L1educ L1scheduled L1backward L1satisfaction L1expend, vce(cluster unique_id)
* Subsample models
eststo: xtreg tvadopted L1logexpenses L1logsavings L1debt if installed==1, vce(cluster unique_id)
eststo: xtreg tvadopted L1logexpenses L1logsavings L1debt L1risk L1business L1riskaverse if installed==1, vce(cluster unique_id)
eststo: xtreg tvadopted L1logexpenses L1logsavings L1debt L1risk L1business L1riskaverse L1trust_people_index L1trust_firms_index if installed==1, vce(cluster unique_id)
eststo: xtreg tvadopted L1logexpenses L1logsavings L1debt L1risk L1business L1riskaverse L1trust_people_index L1trust_firms_index L1logpublic L1logprivate L1elec L1size L1age L1educ L1scheduled L1backward L1satisfaction L1expend if installed==1, vce(cluster unique_id)

/*

esttab using "./Adopt_panelOLS.tex", replace b(%9.2f) booktabs stats(N N_clust, labels("Observations" "Habitations") fmt(0 0)) /// 
eqlabels(none) noconstant se label nonotes legend star(* 0.10 ** 0.05 *** 0.01) ///
mtitles("Model" "Model" "Model" "Model" "Model" "Model" "Model" "Model") ///
mgroups("Full sample" "Subsample: MGP service installed", pattern(1 0 0 0 1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
addnote ("Dependent Variable: MGP adoption." "Standard errors in parentheses and clustered by habitation." "All explanatory variables are measured pre-treatment.") 
*/


*	************************************************************************
*	Appendix A5: Regression results (cross-section)
*	************************************************************************

* Reload data
capture log close
clear all
set more off
do "./prep.do"

* Table A8: Logistic regression (cross-section, midline)
eststo clear
eststo: logit tvadopted L1logexpenses L1logsavings L1debt if survey!=3, vce(cluster unique_id)
eststo: logit tvadopted L1logexpenses L1logsavings L1debt L1risk L1business L1riskaverse if survey!=3, vce(cluster unique_id)
eststo: logit tvadopted L1logexpenses L1logsavings L1debt L1risk L1business L1riskaverse L1trust_people_index L1trust_firms_index if survey!=3, vce(cluster unique_id)
eststo: logit tvadopted L1logexpenses L1logsavings L1debt L1risk L1business L1riskaverse L1trust_people_index L1trust_firms_index L1logpublic L1logprivate L1elec L1size L1age L1educ L1scheduled L1backward L1satisfaction L1expend if survey!=3, vce(cluster unique_id)

/*

* NB: Coefficients are odds-ratios, so the esttab command below needs to be run to exp transform coefficients

esttab using "./logit_midline.tex", replace b(%9.2f) booktabs stats(N N_clust r2_p, labels("Observations" "Habitations" "Pseudo $ R^2$") fmt(0 0 3)) /// 
eqlabels(none) eform noconstant se label nonotes legend star(* 0.10 ** 0.05 *** 0.01) ///
mtitles("Model" "Model" "Model" "Model") ///
addnote ("Dependent Variable: MGP adoption." "Standard errors in parentheses and clustered by habitation." "All explanatory variables are measured pre-treatment.") 
*/

* Table A9: Logistic regression (cross-section, endline)
eststo clear
eststo: logit tvadopted L2logexpenses L2logsavings L2debt, vce(cluster unique_id)
eststo: logit tvadopted L2logexpenses L2logsavings L2debt L2risk L2business L2riskaverse, vce(cluster unique_id)
eststo: logit tvadopted L2logexpenses L2logsavings L2debt L2risk L2business L2riskaverse L2trust_people_index L2trust_firms_index, vce(cluster unique_id)
eststo: logit tvadopted L2logexpenses L2logsavings L2debt L2risk L2business L2riskaverse L2trust_people_index L2trust_firms_index L2logpublic L2logprivate L2elec L2size L2age L2educ L2scheduled L2backward L2satisfaction L2expend, vce(cluster unique_id)

/* 

* NB: Coefficients are odds-ratios, so the esttab command below needs to be run to exp transform coefficients

esttab using "./logit_endline.tex", replace b(%9.2f) booktabs stats(N N_clust r2_p, labels("Observations" "Habitations" "Pseudo $ R^2$") fmt(0 0 3)) /// 
eqlabels(none) eform noconstant se label nonotes legend star(* 0.10 ** 0.05 *** 0.01) ///
mtitles("Model" "Model" "Model" "Model") ///
addnote ("Dependent Variable: MGP adoption." "Standard errors in parentheses and clustered by habitation." "All explanatory variables are measured pre-treatment.") 
*/

* Table A10: OLS regression (cross-section, midline)
eststo clear
eststo: reg tvadopted L1logexpenses L1logsavings L1debt if survey!=3, vce(cluster unique_id)
eststo: reg tvadopted L1logexpenses L1logsavings L1debt L1risk L1business L1riskaverse if survey!=3, vce(cluster unique_id)
eststo: reg tvadopted L1logexpenses L1logsavings L1debt L1risk L1business L1riskaverse L1trust_people_index L1trust_firms_index if survey!=3, vce(cluster unique_id)
eststo: reg tvadopted L1logexpenses L1logsavings L1debt L1risk L1business L1riskaverse L1trust_people_index L1trust_firms_index L1logpublic L1logprivate L1elec L1size L1age L1educ L1scheduled L1backward L1satisfaction L1expend if survey!=3, vce(cluster unique_id)

/*
esttab using "./OLS_midline.tex", replace b(%9.2f) booktabs stats(N N_clust r2, labels("Observations" "Habitations" "$ R^2$") fmt(0 0 3)) /// 
eqlabels(none) noconstant se label nonotes legend star(* 0.10 ** 0.05 *** 0.01) ///
mtitles("Model" "Model" "Model" "Model") ///
addnote ("Dependent Variable: MGP adoption." "Standard errors in parentheses and clustered by habitation." "All explanatory variables are measured pre-treatment.") 
*/

* Table A11: OLS regression (cross-section, endline)
eststo clear
eststo: reg tvadopted L2logexpenses L2logsavings L2debt, vce(cluster unique_id)
eststo: reg tvadopted L2logexpenses L2logsavings L2debt L2risk L2business L2riskaverse, vce(cluster unique_id)
eststo: reg tvadopted L2logexpenses L2logsavings L2debt L2risk L2business L2riskaverse L2trust_people_index L2trust_firms_index, vce(cluster unique_id)
eststo: reg tvadopted L2logexpenses L2logsavings L2debt L2risk L2business L2riskaverse L2trust_people_index L2trust_firms_index L2logpublic L2logprivate L2elec L2size L2age L2educ L2scheduled L2backward L2satisfaction L2expend, vce(cluster unique_id)

/*
esttab using "./OLS_endline.tex", replace b(%9.2f) booktabs stats(N N_clust r2, labels("Observations" "Habitations" "$ R^2$") fmt(0 0 3)) /// 
eqlabels(none) noconstant se label nonotes legend star(* 0.10 ** 0.05 *** 0.01) ///
mtitles("Model" "Model" "Model" "Model" "Model") ///
addnote ("Dependent Variable: MGP adoption." "Standard errors in parentheses and clustered by habitation." "All explanatory variables are measured pre-treatment.") 
*/


*	************************************************************************
*	Appendix A6: Regression results (village fixed-effects, panel)
*	************************************************************************

* Make sure that covariates are pre-treatment
tsset Q11_hhid survey
by Q11_hhid: replace L1logexpenses = L1logexpenses[2] if survey==3
by Q11_hhid: replace L1logsavings = L1logsavings[2] if survey==3 
by Q11_hhid: replace L1debt = L1debt[2] if survey==3
by Q11_hhid: replace L1risk = L1risk[2] if survey==3
by Q11_hhid: replace L1business = L1business[2] if survey==3
by Q11_hhid: replace L1riskaverse = L1riskaverse[2] if survey==3
by Q11_hhid: replace L1trust_people_index = L1trust_people_index[2] if survey==3
by Q11_hhid: replace L1trust_firms_index = L1trust_firms_index[2] if survey==3
by Q11_hhid: replace L1logpublic = L1logpublic[2] if survey==3
by Q11_hhid: replace L1logprivate = L1logprivate[2] if survey==3
by Q11_hhid: replace L1elec = L1elec[2] if survey==3
by Q11_hhid: replace L1size = L1size[2] if survey==3
by Q11_hhid: replace L1age = L1age[2] if survey==3
by Q11_hhid: replace L1educ = L1educ[2] if survey==3
by Q11_hhid: replace L1scheduled = L1scheduled[2] if survey==3
by Q11_hhid: replace L1backward = L1backward[2] if survey==3
by Q11_hhid: replace L1satisfaction = L1satisfaction[2] if survey==3
by Q11_hhid: replace L1expend = L1expend[2] if survey==3

* Table A12: Replication of main model results using village fixed-effects
eststo clear

* Full sample models
xi: eststo: xtlogit tvadopted L1logexpenses L1logsavings L1debt i.Q24_village, vce(cluster unique_id)
xi: eststo: xtlogit tvadopted L1logexpenses L1logsavings L1debt L1risk L1business L1riskaverse i.Q24_village, vce(cluster unique_id)
xi: eststo: xtlogit tvadopted L1logexpenses L1logsavings L1debt L1risk L1business L1riskaverse L1trust_people_index L1trust_firms_index i.Q24_village, vce(cluster unique_id)
xi: eststo: xtlogit tvadopted L1logexpenses L1logsavings L1debt L1risk L1business L1riskaverse L1trust_people_index L1trust_firms_index L1logpublic L1logprivate L1elec L1size L1age L1educ L1scheduled L1backward L1satisfaction L1expend i.Q24_village, vce(cluster unique_id)
* Subsample models
xi: eststo: xtlogit tvadopted L1logexpenses L1logsavings L1debt i.Q24_village if installed==1, vce(cluster unique_id)
xi: eststo: xtlogit tvadopted L1logexpenses L1logsavings L1debt L1risk L1business L1riskaverse i.Q24_village if installed==1, vce(cluster unique_id)
xi: eststo: xtlogit tvadopted L1logexpenses L1logsavings L1debt L1risk L1business L1riskaverse L1trust_people_index L1trust_firms_index i.Q24_village if installed==1, vce(cluster unique_id)
xi: eststo: xtlogit tvadopted L1logexpenses L1logsavings L1debt L1risk L1business L1riskaverse L1trust_people_index L1trust_firms_index L1logpublic L1logprivate L1elec L1size L1age L1educ L1scheduled L1backward L1satisfaction L1expend i.Q24_village if installed==1, vce(cluster unique_id)

/* 

* NB: Coefficients are odds-ratios, so the esttab command below needs to be run to exp transform coefficients

esttab using "./panel_villageFE.tex", replace b(%9.2f) booktabs stats(N N_clust, labels("Observations" "Habitations") fmt(0 0)) /// 
eqlabels(none) eform indicate("Village FE = _IQ24_villa_2") drop(_IQ24_villa_* lnsig2u:_cons _cons) noconstant se label nonotes legend star(* 0.10 ** 0.05 *** 0.01) ///
mtitles("Model" "Model" "Model" "Model" "Model" "Model" "Model" "Model") ///
mgroups("Full sample" "Subsample: MGP service installed", pattern(1 0 0 0 1 0 0 0) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
addnote ("Dependent Variable: MGP adoption." "Standard errors in parentheses and clustered by habitation." "All explanatory variables are measured pre-treatment.") 
*/

*	************************************************************************
*	Appendix A7: Regression results (subsample, by survey wave)
*	************************************************************************

* Reload data
capture log close
clear all
set more off
do "./prep.do"

* Table A13: Logistic regression (midline, habitations w/ MGP service)
eststo clear
eststo: logit tvadopted L1logexpenses L1logsavings L1debt if survey!=3 & installed==1, vce(cluster unique_id)
eststo: logit tvadopted L1logexpenses L1logsavings L1debt L1risk L1business L1riskaverse if survey!=3 & installed==1, vce(cluster unique_id)
eststo: logit tvadopted L1logexpenses L1logsavings L1debt L1risk L1business L1riskaverse L1trust_people_index L1trust_firms_index if survey!=3 & installed==1, vce(cluster unique_id)
eststo: logit tvadopted L1logexpenses L1logsavings L1debt L1risk L1business L1riskaverse L1trust_people_index L1trust_firms_index L1logpublic L1logprivate L1elec L1size L1age L1educ L1scheduled L1backward L1satisfaction L1expend if survey!=3 & installed==1, vce(cluster unique_id)

/*

* NB: Coefficients are odds-ratios, so the esttab command below needs to be run to exp transform coefficients

esttab using "./Appendix/Subsample_midline_adopters.tex", replace b(%9.2f) booktabs stats(N N_clust r2_p, labels("Observations" "Habitations" "Pseudo $ R^2$") fmt(0 0 3)) /// 
eqlabels(none) eform noconstant se label nonotes legend star(* 0.10 ** 0.05 *** 0.01) ///
mtitles("Model" "Model" "Model" "Model") ///
addnote ("Dependent Variable: MGP adoption." "Standard errors in parentheses and clustered by habitation." "All explanatory variables are measured pre-treatment.") 
*/

* Table A14: Logistic regression (endline, habitations w/ MGP service)
eststo clear
eststo: logit tvadopted L2logexpenses L2logsavings L2debt if installed==1, vce(cluster unique_id)
eststo: logit tvadopted L2logexpenses L2logsavings L2debt L2risk L2business L2riskaverse if installed==1, vce(cluster unique_id)
eststo: logit tvadopted L2logexpenses L2logsavings L2debt L2risk L2business L2riskaverse L2trust_people_index L2trust_firms_index if installed==1, vce(cluster unique_id)
eststo: logit tvadopted L2logexpenses L2logsavings L2debt L2risk L2business L2riskaverse L2trust_people_index L2trust_firms_index L2logpublic L2logprivate L2elec L2size L2age L2educ L2scheduled L2backward L2satisfaction L2expend if installed==1, vce(cluster unique_id)

/*

* NB: Coefficients are odds-ratios, so the esttab command below needs to be run to exp transform coefficients

esttab using "./Appendix/Subsample_endline_adopters.tex", replace b(%9.2f) booktabs stats(N N_clust r2_p, labels("Observations" "Habitations" "Pseudo $ R^2$") fmt(0 0 3)) /// 
eqlabels(none) eform noconstant se label nonotes legend star(* 0.10 ** 0.05 *** 0.01) ///
mtitles("Model" "Model" "Model" "Model") ///
addnote ("Dependent Variable: MGP adoption." "Standard errors in parentheses and clustered by habitation." "All explanatory variables are measured pre-treatment.") 
*/

*	************************************************************************
*								END OF DO FILE 
*	************************************************************************

